<template>
  <drop-wrap :data="data" :index="index" :element="element">
    <el-form-item
      v-if="element.key"
      :id="element.cid"
      :prop="prop"
      :rules="element.rules"
      :label="element.options.label"
    >
      <el-upload
        action="https://jsonplaceholder.typicode.com/posts/"
        list-type="picture-card"
        :on-preview="handlePictureCardPreview"
        :on-remove="handleRemove"
      >
        <i class="el-icon-plus"></i>
      </el-upload>
      <el-dialog :visible.sync="dialogVisible">
        <img width="100%" :src="dialogImageUrl" alt="" />
      </el-dialog>
    </el-form-item>
  </drop-wrap>
</template>
<script>
export default {
  props: ["element", "data", "index"],
  data() {
    return {
      dialogVisible: false,
      dialogImageUrl: "",
    };
  },
  computed: {
    prop() {
      return `${this.element.fullModelTag}`;
    },
    store() {
      return this.element.getRoot();
    },
  },
  methods: {
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url;
      this.dialogVisible = true;
    },
  },
};
</script>

<style  scoped>
</style>